<?php
/**
 * @title:
 * @desc:
 * @since：2019/7/3 0003  上午 11:28
 */
namespace app\admin\logic;
use app\common\logic\Base;
use app\model\Authrule;
use app\model\RoleAuthrule;

class RoleAdmin extends Base
{

    /**
     * 获取用户权限数据
     */
    static public function getAccess($admin_id) {
        $isSupper = false;//Tools::isAdministrator($admin_id);
        if ($isSupper) {

            $access = (new Authrule())->where("status",0)->column("name");

            return $access;

        } else {
            //$groups = AdminAuthGroupAccess::get(['uid' => $uid]);
            $role_ids = (new RoleAdmin())->where("admin_id",$admin_id)->column("role_id");

            $groups = (new RoleAuthrule())->whereIn("role_id",$role_ids)->column("rule_id");

            $access = (new Authrule())->where("status",0)->whereIn("rule_id",$groups)->column("name");

            return $access;
        }
    }


}